<template>
  <div class="twoData" ref="dataTwo">

  </div>
</template>

<script>
import { fenbuNetWork } from '@/nextwork/nextworks'
var echarts = require('echarts')
export default {
  props: {
    pullTime: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      infoclass: [],
      list: []
    }
  },
  watch: {
    pullTime () {
      this.getFenBu()
    }
  },
  mounted () {
    this.getFenBu()
  },
  methods: {
    getFenBu () {
      fenbuNetWork(this.pullTime).then(res => {
        this.infoclass = res.data.infoclass
        this.list = res.data.list
        this.initEcharts()
      })
    },
    initEcharts () {
      var myChart = echarts.init(this.$refs.dataTwo)
      var option = {
        title: {
          text: '咨询专业分布',
          textStyle: {
            color: '#67C23A'
          },
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          left: 'center',
          bottom: 0,
          data: this.infoclass
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: '60%',
            data: this.list,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      myChart.setOption(option)
    }
  }
}
</script>

<style lang="less" scoped>
.twoData{
  width: 100%;
  height: 500px;
}
</style>
